package cn.frank.framework.king;

import cn.frank.framework.king.conf.init.listener.*;
import cn.frank.framework.king.util.StartUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
@Slf4j
public class KingApplication {

    public static void main(String[] args) throws Exception {

        SpringApplication app = new SpringApplication(KingApplication.class);

        // ✅ 1. 设置自定义 Banner 和 Profile（构建 SpringApplication 阶段）
        app.setBannerMode(Banner.Mode.CONSOLE);
        // app.setAdditionalProfiles("dev");

        // ✅ 2. 添加监听器，观察启动过程各阶段事件
        app.addListeners(
                new EnvironmentPreparedListener(),
                new ContextInitializedListener(),
                new ContextRefreshedListener(),
                new ApplicationReadyListener(),
                new ApplicationFailedListener()
        );

        final ConfigurableApplicationContext context = app.run(args);

        // ✅ 3. 打印配置
        StartUtil.printConfigInfo(context);
        // ✅ 4. 打印配置（指定）
        StartUtil.printConfigInfo(context,"my.maven.version");
    }

}
